package com.tencent.qf.team.controller;

import com.alibaba.fastjson.JSON;
import com.tencent.qf.common.pojo.HttpResult;
import com.tencent.qf.mybatis.pojo.PageRequest;
import com.tencent.qf.mybatis.pojo.PageResult;
import com.tencent.qf.team.dal.DmAppLeaderTaskJoinRecord;
import com.tencent.qf.team.dto.request.LeaderTaskJoinRecordLeaderCountRequest;
import com.tencent.qf.team.dto.request.LeaderTaskJoinRecordUnJoinLeaderCountRequest;
import com.tencent.qf.team.dto.response.LeaderTaskJoinRecordLeaderCountResponse;
import com.tencent.qf.team.service.LeaderTaskJoinRecordService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
public class LeaderTaskJoinRecordController {

    @Autowired
    private LeaderTaskJoinRecordService leaderTaskJoinRecordService;

    @PostMapping("/api/team/leaderTaskJoinRecord/listCanJoinTaskLeaderCount")
    @ApiOperation("批量查找子任务下-可报名团长数")
    public HttpResult<List<LeaderTaskJoinRecordLeaderCountResponse>> listCanJoinTaskLeaderCount(
            @RequestBody LeaderTaskJoinRecordLeaderCountRequest request) {
        log.info("批量查找子任务下-可报名团长数，入参：{}", JSON.toJSONString(request));
        List<LeaderTaskJoinRecordLeaderCountResponse> data = leaderTaskJoinRecordService.listCanJoinTaskLeaderCount(request);
        HttpResult<List<LeaderTaskJoinRecordLeaderCountResponse>> result = HttpResult.success(data);
        log.info("批量查找子任务下-可报名团长数，出参：{}", JSON.toJSONString(result));
        return result;
    }

    @PostMapping("/api/team/leaderTaskJoinRecord/listUnJoinTaskLeader")
    @ApiOperation("未报名任务-团长列表(分页)")
    public HttpResult<PageResult<DmAppLeaderTaskJoinRecord>> listUnJoinTaskLeader(
            @RequestBody PageRequest<LeaderTaskJoinRecordUnJoinLeaderCountRequest> request) {
        log.info("未报名任务-团长列表(分页)，入参：{}", JSON.toJSONString(request));
        PageResult<DmAppLeaderTaskJoinRecord> data = leaderTaskJoinRecordService.listUnJoinTaskLeader(request);
        HttpResult<PageResult<DmAppLeaderTaskJoinRecord>> result = HttpResult.success(data);
        log.info("未报名任务-团长列表(分页)，出参：{}", JSON.toJSONString(result));
        return result;
    }
}
